<!--
 * @Author: 吴竹叶 2107206923@qq.com
 * @Date: 2023-10-17 10:48:24
 * @LastEditors: 吴竹叶 2107206923@qq.com
 * @LastEditTime: 2023-11-07 16:05:51
 * @FilePath: \BZ_JT_AnQuanHuanBaoGuanLiApp\src\views\staging\carbon\emissionData\components\dataDisplay.vue
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<template>
  <div>
    <div v-for="(item, index) in descList" :key="index">
      <customTitle :is-line="true" bg-color="#3795ff" :title="item.label" />
      <div class="loading">
        <div v-for="(it, ind) in item.value" :key="ind">
          <custom-details-item :icon="it.icon" :label="it.label" :value="it.value">
            <template #valueSlot>
              <span>{{ desData[it.value] || '/' }}</span>
            </template>
          </custom-details-item>
        </div>
      </div>
      <customTitle :is-line="true" bg-color="#3795ff" title="温室气体排放量汇总表" />
      <el-table :data="listData" style="width: 100%" size="small" class="tableList mt-1 loadingbottom">
        <el-table-column prop="type" label="源类别" align="center" min-width="120" />
        <el-table-column prop="value" label="温室气体二氧化碳当量（单位：万吨二氧化碳当量）" align="center" />
      </el-table>
    </div>
  </div>
</template>

<script>
import { dataView } from '@/api/carbon'
export default {
  inject: ['layout'],
  data() {
    return {
      descList: [
        {
          label: '基本信息',
          value: [
            { label: '企业名称', value: 'companyName', icon: '' },
            { label: '年份', value: 'year', icon: '' },
            { label: '行业类别', value: 'industry', icon: '' },
            { label: '集团分级评价等级', value: 'estimationScale', icon: '' },
            // { label: '纳入全国碳市场的行业子类', value: 'industrySubType', icon: '' },
            { label: '行政区划', value: 'address', icon: '' }
          ]
        }
      ],
      listData: [
        {
          type: '化石燃料燃烧二氧化碳排放量',
          name: 'fossil',
          value: ''
        },
        {
          type: '电力、热力二氧化碳排放量',
          name: 'electricityHeat',
          value: ''
        },
        {
          type: '工业生产过程二氧化碳排放量',
          name: 'industrialProcesses',
          value: ''
        },
        {
          type: '其中：净购入电力二氧化碳排放量',
          name: 'netPurchases',
          value: ''
        },
        {
          type: '其中：净购入热力二氧化碳排放量',
          name: 'heatingPower',
          value: ''
        },
        {
          type: '其中：外购绿电绿证二氧化碳排放量',
          name: 'outsourcing',
          value: ''
        },
        {
          type: '碳排放量（吨二氧化碳当量）',
          name: 'dischargeValue',
          value: ''
        }
      ],
      desData: {}
    }
  },
  mounted() {
    const { current } = this.$route.query
    this.current = current
    this.desData = this.$route.query
    this.listData.map((v) => {
      v.value = this.$route.query[v.name] ?? ''
    })
  },
  methods: {
    async dataView() {
      this.layout.showAreaLoading(['.loading '])
      this.layout.showAreaLoading(['.loadingbottom '])

      const { status, data } = await dataView({ id: this.id })
      if (status === 0 && data) {
        this.desData = data
        // this.listData = data.dataList

        this.listData.map((v) => {
          v.value = data[v.name] ?? ''
        })
      }
      this.layout.hideAreaLoading(['.loading '])
      this.layout.hideAreaLoading(['.loadingbottom '])
    }
  }
}
</script>
